﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using Lottery.Control;

namespace Lottery.MediaData.UI.Control {
    public partial class SCInput : UserControl {
        public SCInput() {
            InitializeComponent();

            m_controls.Add(scControl1);
            m_controls.Add(scControl2);
            m_controls.Add(scControl3);
            m_controls.Add(scControl4);
            m_controls.Add(scControl5);
            m_controls.Add(scControl6);
            m_controls.Add(scControl7);
            m_controls.Add(scControl8);
            m_controls.Add(scControl9);
            m_controls.Add(scControl10);
            m_controls.Add(scControl11);
            m_controls.Add(scControl12);
            m_controls.Add(scControl13);
            m_controls.Add(scControl14);
            for (int i = 0; i < Count; i++) {
                m_controls[i].Order = i + 1;
            }
        }

        private List<SCControl> m_controls = new List<SCControl>();

        public SCControl this[int index] {
            get {
                return m_controls[index];
            }
        }

        public int Count { get { return 14; } }

        public void ClearData() {
            for (int i = 0; i < 14; i++) {
                var emd = m_controls[i];
                emd.Clear();
            }
        }

        public void SetEachData(int index, int? three, int? one, int? zero, string preNumber) {
            var item = m_controls[index];
            item.Order = index;
            item.Set310(three, one, zero);
            item.PreNumber = preNumber;
        }

        public void SetCC(List<int> cc) {
            var list = cc;
            var cl = new List<SCControl>();
            for (int i = 0; i < this.Count; i++) {
                var item = this[i];
                var isOK = list.IndexOf(i) != -1;
                item.Enabled = isOK;
                if (isOK) cl.Add(item);
            }

            for (int i = 0; i < cl.Count; i++) {
                if (i < cl.Count - 1) {
                    cl[i].JumpToNext = cl[i + 1];
                }
            }
        }
    }
}
